'use strict';
exports.main = async (event, context) => {
	//event为客户端上传的参数
	console.log('event : ', event)

	// 生成阅读ID
	let read_id = (new Date().getTime().toString().slice(-4)) + "_" + (Math.random().toString().slice(2));
	// 创建的时间戳
	let read_create_time = new Date().getTime();
	let read_isShow = false;
	// 解构赋值
	let {
		book_sourceUuid,
		book_category,
		book_title,
		book_author,
		book_img,
		book_description,
	} = event;


	// 链接云数据库
	const db = uniCloud.database();
	const read = db.collection('db_read')

	// 添加
	return await read.add({
		read_id,
		read_create_time,
		book_sourceUuid,
		book_category,
		book_title,
		book_author,
		book_img,
		book_description,
		read_isShow
	})
	.then(content => {
		return content;
		console.log('add==',content);
	})
	//返回数据给客户端
};